import request from "./request"

// 登录
export function loginform(data) {
    return request({
        url: "/login",
        method: "POST",
        data
    })
}
// 左侧菜单
export function zuocecaidan() {
    return request({
        url: "/menus",
        method: "GET",
    })
}
// 渲染用户列表
export function yonghuliebiao(params) {
    return request({
        url: "users",
        method: "get",
        params
    })
}
// 修改用户状态
export function xiugaizhuangtai(id, zt) {
    return request({
        url: `users/${id}/state/${zt}`,
        method: "put"
    })
}
// 添加用户
export function tianjiayonghu(data) {
    return request({
        url: "users",
        method: "post",
        data
    })
}
// 编辑用户
export function bianjiyonghu(data) {
    return request({
        url: `users/${data.id}`,
        method: "put",
        data
    })
}
// 删除用户
export function shanchuyonghu(id) {
    return request({
        url: `users/${id}`,
        method: "delete"
    })
}
// 角色列表
export function jueseliebiao() {
    return request({
        url: "roles",
        method: "get"
    })
}
// 分配角色
export function fenpeijuese(id, rid) {
    return request({
        url: `users/${id}/role`,
        method: "put",
        data: { rid }
    })
}
// 添加角色
export function tianjiajuese(data) {
    return request({
        url: "roles",
        method: "post",
        data
    })
}
// 编辑角色
export function bianjijuese(data) {
    return request({
        url: `roles/${data.id}`,
        method: "put",
        data
    })
}
// 删除角色
export function shanchujuese(id) {
    return request({
        url: `roles/${id}`,
        method: 'delete'
    })
}
// 角色权限列表
export function juesequanxian(type = "tree") {
    return request({
        url: `rights/${type}`,
        method: "get"
    })
}
// 角色授权
export function jueseshouquan(roleId, rids) {
    return request({
        url: `roles/${roleId}/rights`,
        method: "post",
        data: { rids }
    })
}
// 删除角色指定权限
export function shanchujuesezhidingid(roleId, rightId) {
    return request({
        url: `roles/${roleId}/rights/${rightId}`,
        method: "delete"
    })
}
// 商品列表
export function shangpinliebiao(params) {
    return request({
        url: "goods",
        method: "get",
        params
    })
}
// 商品删除
export function shanchushangpin(id) {
    return request({
        url: `goods/${id}`,
        method: 'delete'
    })
}
// 商品分类
export function shangpinfenlei(params) {
    return request({
        url: "categories",
        method: "get",
        params
    })
}
// 编辑提交分类
export function bianjitijiaofenlei(id, cat_name) {
    return request({
        url: `categories/${id}`,
        method: "put",
        data: { cat_name }
    })
}
// 删除分类
export function shanchufenlei(id) {
    return request({
        url: `categories/${id}`,
        method: "delete"
    })
}
// 添加分类
export function tianjiafenlei(data) {
    return request({
        url: "categories",
        method: "post",
        data
    })
}
// 添加商品
export function tianjiashangpin(data) {
    return request({
        url: "goods",
        method: "post",
        data
    })
}
// 参数列表
export function canshuliebiao(id, sel = 'many') {
    return request({
        url: `categories/${id}/attributes`,
        method: "get",
        params: { sel }
    })
}
// 订单列表
export function dingdanliebiao(params) {
    return request({
        url: "orders",
        method: "get",
        params
    })
}
// 编辑提交参数
export function bianjitijiaocanshu(id, attrId, data) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: "put",
        data
    })
}
// 添加动态参数或静态参数
export function tianjiajingtaidongtaicanshu(id, data) {
    return request({
        url: `categories/${id}/attributes`,
        method: "post",
        data
    })
}
// 删除参数
export function shanchucanshu(id,attrid){
    return request({
        url:`categories/${id}/attributes/${attrid}`,
        method:"DELETE"
    })
}
// 数据统计
export function shujutongji(){
    return request({
        url:`reports/type/1`,
        method:"get"
    })
}